# -*- coding: utf-8 -*- 


import m_main

import m_database

#在win7系统下需要把这一段注释掉的代码启用
import sys
default_encoding = 'utf-8'
if sys.getdefaultencoding() != default_encoding:
    reload(sys)
    sys.setdefaultencoding(default_encoding)


if __name__=='__main__':
    while True:
        ilist=[]
        xxx=m_database.MyDatabaseTmall()
        mytuple=xxx.fetchdata('select usercode,fullname from customer where usetag is null and usercode is not null order by usercode limit 2000')
        for x,y in mytuple:
            #print x,y
            task1=m_main.Task()
            task1.to_downloader='Downloader_Common'
            task1.to_spider='Spiders_Tmall_Findcustomer'
            task1.url='http://my.taobao.com/'+x+'/follows.htm'
            task1.refdata={'customerName':y}
            
            task2=m_main.Task()
            task2.to_downloader='Downloader_Common'
            task2.to_spider='Spiders_Tmall_Findcustomer'
            task2.url='http://my.taobao.com/'+x+'/fans.htm'
            task2.refdata={'customerName':y}
            
            ilist.append(task1)
            ilist.append(task2)
        m_main.scrapyEngine(ilist)
